package com.tfblog.blog.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * Created by FengBin on 2021/4/26 21:07
 * 使用Swagger2进行前后端分离的联调
 */
@Configuration
@EnableSwagger2
public class MySwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .enable(false)     //暂时不启动swagger
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tfblog.blog.controller"))
                .paths(PathSelectors.any())
                .build();

    }


    //获取文档配置信息
    private ApiInfo apiInfo() {
        Contact contact = new Contact("feng", "http://tfblog.com", "fb1994email@163.com");
        return new ApiInfo(
                "tfblog-swagger",
                "博客项目前后端分离调试工具",
                "v1.0",
                "http:term.service.com",
                contact,
                "Apach 2.0 许可",
                "许可连接",
                new ArrayList<>()
        );
    }

}
